
	<?php
	$j=0;
	//$sels = Sel::model()->findAllByAttributes(array("idtype"=>$type,"iddomaine"=>$domaine,"status"=>1),array("order"=>"nom asc"));
	//$grains = Grain::model()->findAll("idtype=$type AND iddomaine=$domaine AND (status=1 or idseliste=" . Yii::app()->user->id . ")",array("order"=>"nom asc"));
	$grains = Grain::model()->findAll("idtype=$type AND iddomaine=$domaine",array("order"=>"nom asc"));
	foreach ($grains as $grain) {
		// on regarde si l'utilisateur courant a le droit de visualiser le grain
		if ($grain->status==1 || $grain->idseliste==Yii::app()->user->id || Yii::app()->user->admin_grain) {
			if ($j==0) echo "<div class=\"btn-group col-lg-11 col-lg-offset-1\" data-toggle=\"buttons\">";
			$j++;
			echo "<label class=\"btn btn-primary" . (in_array($grain->id,$grains_seliste) ? " active" : ""); 
			if ($grain->status==0) echo " unvalidate\" data-toggle=\"tooltip\" data-placement=\"top\" title=\"En attente de validation\" data-container=\"body";
			echo "\">";
			echo CHtml::checkBox('checkgrain['.$grain->id.']',in_array($grain->id,$grains_seliste),array("class"=>"checkgrain","data-type"=>$type,"data-domaine"=>$domaine,"data-grain"=>$grain->id));
			echo "<span class=\"check_label\">" . $grain->nom . "</span>";
			if ($grain->status==0) echo " <span class=\"glyphicon glyphicon-eye-close\"></span>";
			echo "</label>";
			if ($j==7) {
				echo "</div>";
				$j=0;
			}
		}
	}
	if ($j>0) echo "</div>";
	?>